package com.visionet.school.app.web.repository.member;

import com.visionet.school.app.web.entity.member.Member;
import com.visionet.school.app.web.entity.member.vo.AsAndMeVo;
import com.visionet.school.app.web.entity.member.vo.AssessVo;
import com.visionet.school.app.web.entity.member.vo.MemberAssessVo;
import com.visionet.school.app.web.entity.vo.MemberVo;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * Created by hxpeng on 2017/3/3.
 */
@Repository
public interface MemberRepository extends PagingAndSortingRepository<Member,String>,JpaSpecificationExecutor<Member> {

    /**
     * 根据学号和名称 查询学生成员
     * @param studentNumber
     * @param memberName
     * @return
     */
    @Query("from Member as m where m.isDeleted = 0 and m.studentNumber = ?1 and m.memberName = ?2 ")
    Member findStudentByNumberAndName(String studentNumber, String memberName);



    @Query("from Member as m where m.id = ?1 and m.isDeleted = 0 ")
    Member findOneById(String memberId);

    @Query("from Member as m where m.id = ?1 and m.isDeleted = 0 ")
    Member getMemberInfo(String memberId);

    @Query("from Member as m where m.memberName like ?1 and m.memberType = ?2 and m.isDeleted = 0")
    List<MemberVo> queryTeacher(String memberName, String memberType);

    @Query("from Member as m where m.memberName = ?1 and m.memberPhone = ?2 and m.isDeleted = 0")
    Member findOneByNameAndPhone(String memberName,String memberPhone);

    Page<MemberVo> findMemberPage(MemberVo memberVo, String sortType);

    //查询所有未添加进班级的学生成员
    Page<MemberVo> queryStudentPage(MemberVo memberVo);

    //根据classID查询所属班级学生信息
    List<MemberAssessVo> getMemberList(String id);

    AsAndMeVo getAssessById(String memberId);


    int findifStatus(String classId);

//    void saveAssess(String classId);

    List<AsAndMeVo> findAssess(String classId);

//    void saveAssess(AssessVo assessVo);//已转移为AssessRepository

    Map<String, Object[]> findAssessReport(String startDate, String endDate, String memberId);

    List<AssessVo> findAssessReportFraction(String startDate, String endDate, String memberId);

    public int findAssessReportFractionSize(String startDate, String endDate, String memberId);

}
